import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { h } from 'vue';
import { Icon } from '/@/components/Icon';
import { Select } from 'ant-design-vue';
export const columns: BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'name',
    width: 100,
    ellipsis: true,
    resizable: true,
  },
  {
    title: '脚本',
    dataIndex: 'batchValue',
    width: 100,
    ellipsis: true,
    resizable: true,
    customRender: ({ record }) => {
      if (record.type == 'batchBtn') {
        return scriptSlotList[0].label;
      } else if (record.type == 'script') {
        return scriptSlotList[1].label;
      } else if (record.type == 'flowBtn') {
        return scriptSlotList[2].label;
      } else if (record.type == 'moduleBtn') {
        return scriptSlotList[3].label;
      }
    },
  },
  {
    title: '可见角色',
    dataIndex: 'roleDescs',
    width: 100,
    ellipsis: true,
    resizable: true,
  },
  {
    title: '顺序号',
    dataIndex: 'btnOrder',
    width: 100,
    ellipsis: true,
    resizable: true,
  },
  {
    title: '样式',
    dataIndex: 'icon',
    width: 100,
    ellipsis: true,
    resizable: true,
    customRender: ({ text }) => {
      return h(
        'div',
        {
          style: 'display:flex;justify-content:center;',
        },
        text && text != '#' && text != 'none'
          ? [
              h(Icon, {
                icon: text,
              }),
            ]
          : [],
      );
    },
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'btnName',
    label: '名称',
    required: true,
    component: 'Input',
    colProps: { span: 24 },
  },
  {
    field: 'btnNewName',
    label: '名称',
    required: true,
    component: 'Input',
    colProps: { span: 24 },
  },
  {
    field: 'scriptSlot',
    label: '脚本',
    component: 'Select',
    colProps: { span: 24 },
    defaultValue: 'module',
    slot: 'scriptSlot',
  },
  {
    field: 'role',
    label: '链接可见角色',
    component: 'Input',
    colProps: { span: 24 },
    helpMessage: '为空则表示角色不限，均可以看见此按钮',
    slot: 'role',
  },
  {
    field: 'btnOrder',
    label: '顺序号',
    component: 'InputNumber',
    colProps: { span: 24 },
  },
  {
    field: 'iconLinkAdd',
    label: '样式',
    component: 'Input',
    colProps: { span: 24 },
    slot: 'iconLinkAdd',
  },
];

export const scriptSlotList = [
  {
    label: '批处理',
    value: '0',
  },
  {
    label: '脚本',
    value: '1',
  },
  {
    label: '流程',
    value: '2',
  },
  {
    label: '添加模块',
    value: '3',
  },
];

export const isSelRowList = [
  {
    label: '无需选择记录',
    value: false,
  },
  {
    label: '需选择记录',
    value: true,
  },
];
export const modeList = [
  {
    label: '对话框',
    value: 1,
  },
  {
    label: '抽屉',
    value: 0,
  },
];
